<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


  <title>My JSP 'courseAll.jsp' starting page</title>

  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
  <link rel="stylesheet" type="text/css" href="styles.css">
  -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
  <style type="text/css">
    .div_list {
      width: 75%;
      margin: 0 auto;
      margin-top: 50px;
      margin-left: 20%;

    }
    #tableClass{
      margin:0 auto;
      width: 100%

    }
    .form1{
      width: 200px;
      display: inline-block
    }
    font {
      color: red;
      font-weight: bold;
      text-align: center;
    }
    table{
      margin:0 auto;

    }
    table tr td{
      text-align: center;
      width:150px;
      height:40px;
    }
    a{
      text-decoration: none;
      cursor:pointer;
    }
  </style>
  <script src="${pageContext.request.contextPath}/js/jquery-1.11.1.min.js"></script>

  <script type="text/JavaScript">
    //分页
    function getPage(page){
      //1.把page设置到查询表单的隐藏域
      $("#page").val(page);
      //2.获取表单对象提交
      $("#myForm").submit();
    }
  </script>
</head>

<body>
<h4 align="center">
  <form action="${pageContext.request.contextPath}/ServletFindAllBook" method="post" id="myForm">
    书名：<input type="text" name="bname"
              placeholder="请输入查询条件" value="${book.bname}"> 类型： <select name="tid" style="height: 22px">
    <option value="-1">请选择</option>
    <!--从数据库中动态获取  -->
    <c:forEach items="${tlist}" var="t">
      <option value="${t.tid}" ${t.tid==book.tid?"selected":""}>${t.tname}</option>
    </c:forEach>
  </select>
    <!--编写一个当前页的隐藏域  -->
    <input type="hidden" name="page" id="page" value="1"> <input
          type="submit" value="查询">
  </form>
</h4>
<div class="div_list panel panel-default">
  <div class="panel-heading">图书信息</div>
  <table class="table panel-body" id="tableClass">
    <tr>
      <td>编号</td>
      <td>图片</td>
      <td>发行日期</td>
      <td>名称</td>
      <td>价格</td>
      <td>数量</td>
      <td>作者</td>
      <td>类型</td>
    </tr>
    <c:forEach var="list" items="${pageUtil.list}">
      <tr>
        <td>${list.getBid() }</td>
        <td>
          <img src="${pageContext.request.contextPath}/upload/${list.getImgurl()==null?"ts.jpeg":list.getImgurl()}" width="50px">
        </td>
        <td>${list.getBdate()}</td>
        <td>${list.getBname()}</td>
        <td>${list.getBprice() }</td>
        <td>${list.getBnumber() }</td>
        <td>${list.getBauthor() }</td>
        <td>${list.getTypee().getTname() }</td>
      </tr>
    </c:forEach>
    <tr>
      <td colspan="9">总记录数：${pageUtil.totalCount}
        当前页/总页数：${pageUtil.currentPage}/${pageUtil.totalPages} &nbsp;&nbsp;&nbsp;
        <a href="#" onclick="getPage(1)">首页</a>
        <a href="#" onclick="getPage(${pageUtil.prevPage })">上一页</a>
        <a href="#" onclick="getPage(${pageUtil.nextPage })">下一页</a>
        <a href="#" onclick="getPage(${pageUtil.totalPages })">尾页</a>
      </td>
    </tr>

  </table>
</div>
</body>
</html>
